Visualizations using tmap
This report uses data from the Office of Spill Prevention and Response (OSPR) Incident Tracking Database, a statewide oil spill tracking information system. The data are collected by OSPR Field Response Team members for Marine oil spills and by OSPR Inland Pollution Coordinators and Wardens for Inland incidents.This data set includes oil spill incidents from 2008 (4 of 3,237 incidents in this data set occurred on 12/31/2007). This data is used to provide the Office of Spill Prevention and Response (OSPR) with quantified statistical evaluation and justification for public education programs, policy analysis, budgeting and training, and to analyze OSPRs overall preparedness and response performance.
Data Citation: California Department of Fish and Wildlife (CDFW); Office of Spill Prevention and Response (OSPR). 2020. Oil Spill Incident Tracking [ds394]. https://gis.data.ca.gov/datasets/7464e3d6f4924b50ad06e5a553d71086_0/explore?showTable=true
# First, read in the California counties shapefile, then use clean_names() to set all names to lower snake case. Then simplify by only keeping two attributes: NAME (county name) and ALAND (land area), then renaming those to `county_name` and `land_area`.
ca_counties_sf <- read_sf(here("data", "ca_counties", "CA_Counties_TIGER2016.shp")) %>%
janitor::clean_names() %>%
select(county_name = name, land_area = aland)
# Next, read in the CA oil spill data, then use clean_names() to set all names to lower snake case.
ca_oil_spills <- read_sf(here("data", "Oil_Spill_Incident_Tracking_[ds394]", "Oil_Spill_Incident_Tracking_[ds394].shp")) %>%
clean_names()
This report includes two maps. One interactive map that shows individual incidents of oil spills throughout the state of California (marine and inland). The second is a static map that shows the density of inland oil spill incidents by county. In this data set, an “incident” is “a discharge or threatened discharge of petroleum or other deleterious material into the waters of the state.”
# We need to ensure that the coordinate reference system (CRS) from the California counties and for the California oil spills match.
# Check CRS for ca_counties_sf
##ca_counties_sf %>% st_crs()
# Check CRS for ca_oil_spills
##ca_oil_spills %>% st_crs()
# Set CRS for oil spills to be the same as ca_counties_sf
ca_oil_spills_4326_sf <- st_transform(ca_oil_spills, st_crs(ca_counties_sf))
# Then check it:
##ca_oil_spills_4326_sf %>% st_crs()
# Now that they have the same CRS, run a test plot of the two together
#ggplot() +
#geom_sf(data = ca_counties_sf) +
#geom_sf(data = ca_oil_spills_4326_sf, size = 1, color = "red")
# They appear to be working together
# Create an exploratory interactive map in tmap showing the location of oil spill events included in the data
# Set the viewing mode to "interactive":
tmap_mode(mode = "view")
# Create and customize my interactive tmap with the polygon fill color updated by variable 'land_area', updating the color palette to "BuGn", then add another shape layer for the oil spill records (added as dots):
tm_shape(ca_counties_sf) +
tm_fill("land_area", palette = "BuGn", title = "Land Area (meters squared)") +
tm_shape(ca_oil_spills_4326_sf) +
tm_dots()